	var TIMELINE = {
		init	: function(){
			var self = this;	
            if(!self.checked_init){
                self.checked_init = true;
                console.log("call");
			    self.EXTERNAL.init();
			    self.UI.init();
            }
		},
        checked_init: false,
        photo_data  : {},
		total_count	: 0,
		m_level		: 6,
		m_idx		: 0,
		m_emotion_point : 0
	}

	TIMELINE.UI = {
		emotion_flag	 : ['ㅡ_ㅡ','O_O','^__^','^O^'],
	    $txt_status : $("#txt_status"),	
		$facebook : jQuery("#facebook"),
		$twitter : jQuery("#twitter"),
		$activity_point : $("#activity_point"),
		$emotion_point : $("#emotion_point"),
		$activity_rate : jQuery("#activity_rate"),
		$baloon_emotion: jQuery("#baloon_emotion"),
		$emotion_status: jQuery("#emotion_status"),
		$level_box	   : jQuery("div.level_box"),
		$btn_msg_type  : jQuery("ul#msg_type>li"),
		$btn_upload_photo  : jQuery("#upload_photo"),
		$frm_photo  : jQuery("#frm_photo"),
		init	: function(){
			var self = this;
			self.bind();
		},
		bind	: function(){
			var self = this;	


			self.$facebook.click(function(){
				if(TIMELINE.EXTERNAL.info.FACEBOOK == undefined){
					if(confirm("페이스북 계정에 연동이 않되어 있군요...\n 연결 할래요?")){
						go_sns("facebook","TIMELINE");
					}
					return false;
				}	
			});
			
			self.$twitter.click(function(){
				if(TIMELINE.EXTERNAL.info.TWITTER == undefined){
					if(confirm("트위터 계정에 연동이 않되어 있군요...\n 연결 할래요?")){
						go_sns("twitter","TIMELINE");
					}
					return false;
				}	
			});
            
            self.check_uploaded = false;

			self.$btn_upload_photo
				.change(function(){
                    if(self.check_uploaded) return false;
                    self.check_uploaded = true;
					if(this.value.length < 1) return false;
                    self.$txt_status.attr({"disabled" : "true"});
					self.$frm_photo.ajaxSubmit({
						url: "/timeline.php?service=api_timeline_upload_photo",
						type: "POST",
						dataType: "json",
						success: function(data){
                            console.log(data);
							if(!data.RESULT_SET.flag){
								alert(data.RESULT_SET.msg);
								return false;
							}
                            TIMELINE.photo_data = data.RESPONSE.result[0];
                            self.$txt_status.removeAttr('disabled');

						}
					});
				});

		}
	}

	TIMELINE.EXTERNAL = {
        type    : "",
		info	: {},
		init	: function(){
			var self = this;
			self.getExternalInfo();
		},
		getExternalInfo		: function(){
			var self = this; 
			var sendData = {
				"service"	: "api_get_externalInfo"
			};

			$.ajax({
				url     : "/timeline.php",
				type    : "get",
				async	: false,
				dataType: "json",
				data    : sendData,
				success : function(data){
					if(!data.RESULT_SET.flag){
						alert(data.RESULT_SET.msg);
						return false;
					}
					self.info =data.RESPONSE;
				} 
			}); 
		},

	    set_status_insert	: function(){
			var self = this;
			var $txt_status = $("#txt_status");	
			var $facebook = $("#facebook");	
			var $twitter = $("#twitter");

			if($txt_status.val().length < 1){
				alert("Hey! Damn it!! Have to write message");
				return false;
			}

			var sendData = {
				"service"	: "api_timeline_status_insert",
				"content"	: $txt_status.val(),
				"type"		: TIMELINE.photo_data.path == undefined ? "TEXT" : "PHOTO",
				"facebook"	: $facebook.attr("checked"),
				"twitter"	: $twitter.attr("checked"),
				"h_file"	: TIMELINE.photo_data.path
			};	
			$txt_status.val("Saving....");
			$txt_status.attr({"disabled" : "true"});
			$.ajax({
				url     : "/timeline.php",
				type    : "post",
				dataType: "json",
				data    : sendData,
				success : function(data){

					TIMELINE.UI.$btn_upload_photo.val("");
					$txt_status.removeAttr("disabled");
					$txt_status.val("");
					alert(data.RESULT_SET.msg);
					if(!data.RESULT_SET.flag){
						return false;
					}
                    TIMELINE.photo_data = {};
				} 
			}); 

		}

	}

